package cn.org.xuanguang.kepler.hormos.rdb.dml;


import cn.org.xuanguang.kepler.hormos.orm.acl.IPolicyInterceptorChain;
import cn.org.xuanguang.kepler.hormos.rdb.dml.operator.NativeDmlOperator;
import cn.org.xuanguang.kepler.hormos.rdb.dml.operator.delete.DeleteOperator;
import cn.org.xuanguang.kepler.hormos.rdb.dml.operator.insert.InsertOperator;
import cn.org.xuanguang.kepler.hormos.rdb.dml.operator.select.SelectOperator;
import cn.org.xuanguang.kepler.hormos.rdb.dml.operator.update.UpdateOperator;
import cn.org.xuanguang.kepler.hormos.rdb.executor.SyncSqlExecutor;

/**
 * 抽象DML操作，所有的curd操作器均通过dml进行操作
 */
public interface Dml {

    /**
     * dml执行器总入口
     *
     * @param syncSqlExecutor
     * @param dialect         数据库断言
     * @return
     */
    public static Dml of(SyncSqlExecutor syncSqlExecutor, String dialect) {
        return new DefaultDml(syncSqlExecutor, dialect, null);
    }

    /**
     * 含拦截器模式的dml
     *
     * @param syncSqlExecutor
     * @param dialect
     * @return
     */
    public static Dml of(SyncSqlExecutor syncSqlExecutor, String dialect, IPolicyInterceptorChain policyInterceptorChain) {
        return new DefaultDml(syncSqlExecutor, dialect, policyInterceptorChain);
    }
    //ddl操作区
    /**
     * insert操作
     *
     * @return
     */
    public InsertOperator createInsertOperator();

    /**
     * 查询操作
     *
     * @return
     */
    public SelectOperator createSelectOperator();
//

    /**
     * 修改操作
     *
     * @return
     */
    public UpdateOperator createUpdateOperator();
    /**
     * 创建一个删除操作符的实例。
     *
     * @return DeleteOperator 返回一个DeleteOperator实例，该实例可用于执行删除操作。
     */
    public DeleteOperator createDeleteOperator();
    /**
     * 创建原生dml操作
     *
     * @return
     */
    public NativeDmlOperator createNativeDmlOperator();

}
